home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 November / Chip Kasım 2001.iso / prog / amapi3d / data1.cab / Common / MACROS / ADDCURV.TCL next >
Encoding:
Text File  |  2000-08-11  |  1.8 KB  |  78 lines

  1. #SPEC -realnameid 0
  2.  
  3. # messages table
  4. #@@%000@@FR@@Ajouter un point \`a une courbe@@
  5. #@@%000@@US@@Add point to curve@@
  6.  
  7. while {[.event shift] != "right"} {
  8.  
  9.     if { [llength [.amapi scene]] == 0 } return
  10.     
  11.     placepoint
  12.     if {[.event shift] == "right"} break
  13.     
  14.     set mysh [.amapi current]
  15.     newshape oldshape $mysh
  16.     if { [oldshape -curve] == 0 } return
  17.     
  18.     oldshape -checkout
  19.     
  20.     set alledges [oldshape -edges]
  21.     set allpoints [oldshape -points]
  22.     set nbedges [llength $alledges]
  23.     
  24.     # nearest edge
  25.     set edg [find -edge [.event mousepos] $mysh]
  26.     
  27.     if { $edg != "" } {
  28.         newshape incrshape {
  29.             for {set i 0} { $i <= [lindex $edg 0] } {incr i} {
  30.                 set curedge [lindex $alledges $i]
  31.                 set curpoint [lindex $curedge 0]
  32.                 addpoint [lindex $allpoints $curpoint]
  33.             }
  34.             
  35.             incr i -1
  36.             set nextpoint [lindex $curedge 1]
  37.             set curcoord [lindex $allpoints $curpoint]
  38.             set nextcoord [lindex $allpoints $nextpoint]
  39.         
  40.             set curcoordx [lindex $curcoord 0]
  41.             set curcoordy [lindex $curcoord 1]
  42.             set curcoordz [lindex $curcoord 2]
  43.         
  44.             set nextcoordx [lindex $nextcoord 0]
  45.             set nextcoordy [lindex $nextcoord 1]
  46.             set nextcoordz [lindex $nextcoord 2]
  47.         
  48.             set midx [expr ($curcoordx + $nextcoordx) / 2]
  49.             set midy [expr ($curcoordy + $nextcoordy) / 2]
  50.             set midz [expr ($curcoordz + $nextcoordz) / 2]
  51.             
  52.             addpoint [list $midx $midy $midz]
  53.         
  54.             incr i
  55.             
  56.             while { $i < $nbedges } {
  57.                 set curedge [lindex $alledges $i]
  58.                 set curpoint [lindex $curedge 0]
  59.                 addpoint [lindex $allpoints $curpoint]
  60.                 incr i
  61.             }
  62.             
  63.             incr i -1
  64.             set curedge [lindex $alledges $i]
  65.             set nextpoint [lindex $curedge 1]
  66.             addpoint [lindex $allpoints $nextpoint]
  67.         }
  68.         
  69.         if {[oldshape -closed]} {
  70.             incrshape -status close
  71.         } else {
  72.             incrshape -status open
  73.         }
  74.         incrshape -checkin
  75.     } else {
  76.         oldshape -checkin
  77.     }
  78. }